import request from '@/utils/request'
//查看购物车
export const getshopcart = () => {
  return request.get('/shoppingCart/getMyShoppingCart')
}
//添加商品到购物车
export const addshopcart = (goodsId) => {
  return request.post(`/shoppingCart/add/${goodsId}`)
}
//从购物车删除商品
export const delshopcart = (id) => {
  return request.delete(`/shoppingCart/delete/${id}`)
}
//清空购物车
export const clearshopcart = () => {
  return request.delete('/shoppingCart/clear')
}
//购买商品接口
export const buygoodService = (id) => {
  return request.post(`/goods/buy/${id}`, { description: '11' })
}
//多选购买
export const buygoodcart = (ids) => {
  return request.put('/shoppingCart/buy', null, {
    params: {
      ids: ids // 将idsString作为查询参数传递
    }
  })
}
//上传照片接口
export const upimage = (file) => {
  // 创建一个 FormData 实例
  const formData = new FormData()
  // 假设 avatar 是一个文件对象，比如来自 <input type="file"> 的 File 对象
  // console.log(typeof file)
  formData.append('file', file)
  // console.log(formData)
  return request.post('/common/upload', formData)
}
//查询历史订单接口
export const gethistoryOrders = () => {
  return request.get('/orders/getHistoryOrders')
}
